package com.learn.mapper;

import com.learn.pojo.Order;
import com.learn.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface IOrderMapper {
    /**
     * 查询订单的同事还查询单所属的用户
     * @return
     */
    @Results(
        {
            @Result(property = "id" ,column = "id"),
            @Result(property = "orderTime" ,column = "orderTime"),
            @Result(property = "total" ,column = "total"),
            @Result(property = "user" ,column = "uid",
                    javaType = User.class,one = @One(select = "com.learn.mapper.IUserMapper.findUserById"))
    }
    )
    @Select(" select * from orders")
    public List<Order> findOrderAndUser();

    /**
     * 查询order
     * @param uid
     * @return
     */
    @Select("select * from orders where uid = #{uid}")
    public Order findOrderByUid(Integer uid);

}
